package com.lin.fengxiu.optional;

import org.apache.commons.lang3.builder.ToStringExclude;
import org.junit.Test;

import java.util.Optional;

/**
 * @ClassName OptionalTest
 * @Description TODO
 * @Author wushaopei
 * @Date 2021/3/17 23:46
 * @Version 1.0
 */
public class OptionalTest {

    @Test
    public void testOptional(){
        Optional<String> empty = Optional.empty();
        Optional<String> t1 = Optional.ofNullable(null);
//        empty.get();
//        String s = t.get();

//        String s = t1.orElse("默认值");
//        System.out.println(s);

        String s1 = t1.map(t->t+"b").orElse("c");
        System.out.println(s1);

    }
}
